import 'package:auto_route/auto_route.dart';
import 'package:casdon/app/config/theme/theme_extention.dart';
import 'package:casdon/app/tab_screen.dart';
import 'package:casdon/auto_router.dart';
import 'package:casdon/common/widget/common_app_bar.dart';
import 'package:casdon/common/widget/gradient_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

@RoutePage()
class ServiceSubmitSuccessScreen extends StatelessWidget {
  final String productName;
  final String expectTime; // yyyy-MM-dd

  const ServiceSubmitSuccessScreen({
    super.key,
    required this.productName,
    required this.expectTime,
  });

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CommonAppBar(
        title: '',
        onBack: () => {context.router.popUntilRouteWithName(TabRoute.name)},
      ),
      backgroundColor: Colors.white,
      body: Padding(
        padding: EdgeInsets.symmetric(horizontal: 16.w),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            SizedBox(height: 48.h),
            CircleAvatar(
              radius: 22.5.r,
              backgroundColor: const Color(0xFF52C41A),
              child: Icon(Icons.check, color: Colors.white, size: 22.5.r),
            ),
            SizedBox(height: 16.h),
            Text(
              '预约成功',
              style: context.textTheme.labelLarge?.copyWith(
                color: context.customColorThemeNonNull.textColor1,
              ),
            ),
            SizedBox(height: 8.h),
            Text(
              '客服将在48小时内与你联系',
              style: context.textTheme.bodySmall?.copyWith(
                color: context.customColorThemeNonNull.textColor3,
              ),
            ),
            SizedBox(height: 24.h),
            Column(
              children: [
                Divider(
                  height: 1,
                  color: context.customColorThemeNonNull.gray2,
                ),
                _row(context, '产品型号', productName),

                _row(context, '期望服务时间', expectTime),
                Divider(
                  height: 1,
                  color: context.customColorThemeNonNull.gray2,
                ),
              ],
            ),

            const Spacer(),

            SizedBox(
              child: GradientButton(
                text: '完成',
                height: 44.h,
                borderRadius: 24,
                onPressed: () => Navigator.of(context).pop('main'),
              ),
            ),
            SizedBox(height: 166.h),
          ],
        ),
      ),
    );
  }

  Widget _row(BuildContext context, String label, String value) {
    return Padding(
      padding: EdgeInsets.symmetric(horizontal: 0.w, vertical: 12.h),
      child: Row(
        children: [
          Expanded(
            child: Text(
              label,
              style: context.textTheme.bodyMedium?.copyWith(
                color: context.customColorThemeNonNull.textColor2,
              ),
            ),
          ),
          Text(value, style: context.textTheme.bodyMedium),
        ],
      ),
    );
  }
}
